Tag identification method and apparatus

ABSTRACT

The present invention discloses a tag identification method and apparatus, relates to the field of communications network technologies, which can implement that there are few steps of determining a format of a tag by a device host in an NFC terminal, so that the tag can be quickly processed. In the embodiments of the present invention, a Near Field Communication NFC controller reads a type of a tag; the NFC controller determines whether a format of the tag is an NFC data exchange format NDEF according to the type of the tag; and the NFC controller sends a notification message to a device host when the NFC controller determines that the format of the tag is the NDEF, where the notification message includes that the format of the tag is the NDEF. The solutions provided in the embodiments of the present invention are applicable to identifying a tag.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a continuation of U.S. patent application Ser. No.14/984,041, filed on Dec. 30, 2015, which is a continuation ofInternational Application No. PCT/CN2013/080225, filed on Jul. 26, 2013.Both of the aforementioned applications are hereby incorporated byreference in their entireties.

TECHNICAL FIELD

The present invention relates to the field of communicationstechnologies, and in particular, to a tag identification method andapparatus.

BACKGROUND

Near Field Communication (NFC) is a short-distance wireless connectiontechnology, which can implement communication between electronic devicesat a close distance by means of magnetic field induction, where twodevices implement data exchange by approaching or colliding.

In the prior art, after an NFC terminal detects an NFC tag, a Near FieldCommunication controller (Near Field Communication Controller, NFCcontroller) of the NFC terminal reads entire content of the NFC tag, andthen sends the entire content of the NFC tag to a device host of the NFCterminal; the device host processes the NFC tag. Generally, the devicehost determines, according to the entire content of the NFC tag, whethera format of the NFC tag is in conformity with an NFC data exchangeformat (NFC Data Exchange Format, NDEF).

However, in the prior art, the device host can determine the format ofthe NFC tag only by acquiring the entire content of the NFC tag, whichcauses the device host to read a large amount of data of the NFC tag andperform relatively complex operations.

SUMMARY

Embodiments of the present invention provide a tag identification methodand apparatus, which can implement reducing steps of determining aformat of a tag by a device host in an NFC terminal, so that an NFC tagcan be processed.

According to a first aspect, an embodiment of the present inventionprovides a tag identification method, including:

reading, by a Near Field Communication (NFC) controller, a type of atag;

determining, by the NFC controller, whether a format of the tag is anNFC data exchange format (NDEF) according to the type of the tag; and

sending, by the NFC controller, a notification message to a device hostwhen the NFC controller determines that the format of the tag is theNDEF, where the notification message includes that the format of the tagis the NDEF.

In a first possible embodiment, with reference to the first aspect,before the reading, by the Near Field Communication (NFC) controller,the type of the tag, the method further includes:

receiving, by the NFC controller, a configuration command sent by thedevice host, where the configuration command is used to indicate whetherthe NFC controller performs NDEF detection on the tag.

In a second possible embodiment, with reference to the first aspect orthe first possible embodiment of the first aspect, the determining, bythe NFC controller, whether the format of the tag is the NFC dataexchange format NDEF according to the type of the tag includes:

when the type of the tag is Type 1, determining, by the NFC controller,whether the format of the tag is the NDEF according to header read-onlymemory HR0 in the tag;

when the type of the tag is Type 2, determining, by the NFC controller,whether the format of the tag is the NDEF according to a capabilitycontainer CC in the tag;

when the type of the tag is Type 3, determining, by the NFC controller,whether the format of the tag is the NDEF according to System Code inthe tag; and

when the type of the tag is Type 4, determining, by the NFC controller,whether the format in the tag is the NDEF according to a file identifierof a capability container CC file in the tag.

In a third possible embodiment, with reference to the first aspect oreither of the foregoing possible embodiments of the first aspect, beforethe receiving, by the NFC controller, the configuration command sent bythe device host, the method further includes:

sending, by the NFC controller, a format function message to the devicehost, where the format function message carries information aboutwhether the NFC controller has a capability of performing the NDEFdetection on the tag.

In a fourth possible embodiment, with reference to the third possibleembodiment of the first aspect, before the sending, by the NFCcontroller, the format function message to the device host, the methodfurther includes:

receiving, by the NFC controller, an initialization command sent by thedevice host; and

the sending, by the NFC controller, the format function message to thedevice host includes:

sending, by the NFC controller, an initialization response to the devicehost, where the initialization response carries the information aboutwhether the NFC controller has a capability of performing the NDEFdetection on the tag.

In a fifth possible embodiment, with reference to the first possibleembodiment of the first aspect, the configuration command is furtherused to indicate that the NFC controller performs data type detection onthe tag.

In a sixth possible embodiment, with reference to the first aspect orany one of the foregoing possible embodiments of the first aspect, afterthe sending, by the NFC controller, the notification message to thedevice host, the method further includes:

receiving, by the NFC controller by using an NDEF radio frequencyinterface, a read/write command sent by the device host;

converting, by the NFC controller, the read/write command into an NDEFread/write command; and

performing, by the NFC controller, data reading/writing on the tagaccording to the NDEF read/write command.

According to a second aspect, an embodiment of the present inventionprovides a tag identification apparatus, including:

a reading module, configured to read a type of a tag;

a determining module, configured to determine whether a format of thetag is an NFC data exchange format NDEF according to the type of thetag; and

a sending module, configured to send a notification message to a devicehost when the determining module determines that the format of the tagis the NDEF, where the notification message includes that the format ofthe tag is the NDEF.

In a first possible embodiment, with reference to the second aspect, theapparatus further includes:

a receiving module, configured to receive a configuration command sentby the device host, where the configuration command is used to indicatewhether the NFC controller performs the NDEF detection on the tag.

In a second possible embodiment, with reference to the second aspect orthe first possible embodiment of the second aspect, the determiningmodule is specifically configured to:

when the type of the tag is Type 1, determine whether the format of thetag is the NDEF according to header read-only memory HR0 in the tag;when the type of the tag is Type 2, determine whether the format of thetag is the NDEF according to a capability container CC in the tag; whenthe type of the tag is Type 3, determine whether the format of the tagis the NDEF according to System Code in the tag; and when the type ofthe tag is Type 4, determine whether the format of the tag is the NDEFaccording to a file identifier of a capability container CC file in thetag.

In a third possible embodiment, with reference to the second aspect oreither of the foregoing possible embodiments of the second aspect,

the sending module is further configured to send a format functionmessage to the device host, where the format function message carriesinformation about whether the NFC controller has a capability ofperforming the NDEF detection on the tag.

In a fourth possible embodiment, with reference to the third possibleembodiment of the second aspect, the receiving module is furtherconfigured to receive an initialization command sent by the device host;and

the sending module is further configured to send an initializationresponse to the NFC controller, where the initialization responsecarries the information about whether the

NFC controller has a capability of performing the NDEF detection on thetag.

In a fifth possible embodiment, with reference to the first possibleembodiment of the second aspect, the configuration command is furtherused to indicate that the NFC controller performs data type detection onthe tag.

In a sixth possible embodiment, with reference to the second aspect orany one of the foregoing possible embodiments of the second aspect, thereceiving module is further configured to receive, by using an NDEFradio frequency interface, a read/write command sent by the device host;and

the apparatus further includes:

a converting module, configured to convert the read/write command intoan NDEF read/write command; and

a processing module, configured to perform data reading/writing on thetag according to the NDEF read/write command.

According to a third aspect, an embodiment of the present inventionprovides a tag identification apparatus, where the apparatus includes aNear Field Communication NFC controller and a device host, and the NFCcontroller is connected to the device host, where:

the NFC controller is configured to read a type of a tag; and determinewhether a format of the tag is an NFC data exchange format NDEFaccording to the type of the tag; and the NFC controller sends anotification message to the device host when the NFC controllerdetermines that the format of the tag is the NDEF, where thenotification message includes that the format of the tag is the NDEF;and

the device host is configured to receive the notification message sentby the NFC controller.

In a first possible embodiment, with reference to the third aspect,

the device host is further configured to send a configuration command tothe NFC controller, where the configuration command is used to indicatewhether the NFC controller performs the NDEF detection on the tag; and

the NFC controller is further configured to receive the configurationcommand sent by the device host.

In a second possible embodiment, with reference to the third aspect orthe first possible embodiment of the third aspect, the NFC controller isspecifically configured to: when the type of the tag is Type 1,determine whether the format of the tag is the NDEF according to headerread-only memory HR0 in the tag; when the type of the tag is Type 2,determine whether the format of the tag is the NDEF according to acapability container CC in the tag; when the type of the tag is Type 3,determine whether the format of the tag is the

NDEF according to System Code in the tag; and when the type of the tagis Type 4, determine whether the format of the tag is the NDEF accordingto a file identifier of a capability container CC file in the tag.

In a third possible embodiment, with reference to the third aspect oreither of the foregoing possible embodiments of the third aspect, theNFC controller is further configured to send a format function messageto the device host, where the format function message carriesinformation about whether the NFC controller has a capability ofperforming the NDEF detection on the tag.

In a fourth possible embodiment, with reference to the third possibleembodiment of the third aspect, the device host is further configured tosend an initialization command to the NFC controller; and

the NFC controller is further configured to send an initializationresponse to the device host after receiving the initialization commandsent by the device host, where the initialization response carries theinformation about whether the NFC controller has a capability ofperforming the NDEF detection on the tag.

In a fifth possible embodiment, with reference to the first possibleembodiment of the third aspect, the configuration command is furtherused to indicate that the NFC controller performs data type detection onthe tag.

In a sixth possible embodiment, with reference to the third aspect orany one of the foregoing possible embodiments of the third aspect, thedevice host is further configured to establish an NDEF radio frequencyinterface for performing data transmission with the NFC controller afterreceiving the notification message sent by the NFC controller.

In a seventh possible embodiment, with reference to the sixth possibleembodiment of the third aspect, the device host is further configured tosend, by using the NDEF radio frequency interface, a read/write commandto the NFC controller; and

the NFC controller is further configured to receive, by using the NDEFradio frequency interface, the read/write command sent by the devicehost; convert the read/write command into an NDEF read/write command;and perform data reading/writing on the tag according to the NDEFread/write command.

According to the tag identification method and apparatus provided in theembodiments of the present invention, an NFC controller reads a type ofa tag; and determines whether a format of the tag is an NFC dataexchange format according to the type of the tag; and the NFC controllersends a notification message to a device host when the NFC controllerdetermines that the format of the tag is the NFC data exchange format,where the notification message includes information that the format ofthe tag is the NFC data exchange format.

Compared with the prior art in which a device host can determine aformat of an NFC tag only by acquiring entire content of the NFC tag,which causes the device host to read a large amount of data of the NFCtag and perform relatively complex operations, the embodiments of thepresent invention can implement reducing steps of determining a formatof a tag by a device host in an NFC terminal, so that the NFC tag can beprocessed.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of the presentinvention more clearly, the following briefly introduces theaccompanying drawings required for describing the embodiments or theprior art. Apparently, the accompanying drawings in the followingdescription show merely some embodiments of the present invention, and aperson of ordinary skill in the art may still derive other drawings fromthese accompanying drawings without creative efforts.

FIG. 1 is a flowchart of a tag identification method according to anembodiment of the present invention;

FIG. 2 is a flowchart of another tag identification method according toan embodiment of the present invention;

FIG. 3 is a schematic diagram of a transmission structure, between adevice host and an NFC controller and between the NFC controller and atag, in a tag identification method according to an embodiment of thepresent invention;

FIG. 4 is a schematic structural diagram of a tag identificationapparatus according to an embodiment of the present invention;

FIG. 5 is a schematic structural diagram of another tag identificationapparatus according to an embodiment of the present invention; and

FIG. 6 is a schematic structural diagram of still another tagidentification apparatus according to an embodiment of the presentinvention.

DESCRIPTION OF EMBODIMENTS

The following clearly describes the technical solutions in theembodiments of the present invention with reference to the accompanyingdrawings in the embodiments of the present invention. Apparently, thedescribed embodiments are merely some but not all of the embodiments ofthe present invention. All other embodiments obtained by a person ofordinary skill in the art based on the embodiments of the presentinvention without creative efforts shall fall within the protectionscope of the present invention.

As shown in FIG. 1, an embodiment of the present invention provides atag identification method, and the method includes:

101: An NFC controller reads a type of a tag.

The NFC controller is a controller in an NFC terminal. The NFC terminalmay be a terminal having an NFC function, such as a mobile phone, atablet computer, or a camera. For ease of description, the embodiment isdescribed by using a mobile phone having an NFC function as an example.The NFC controller is a logical entity responsible for transmitting dataon an NFC radio frequency interface. In an example of a mobile phonehaving an NFC function, an NFC controller refers to an NFC chip in themobile phone.

In this embodiment, the tag is an NFC tag. Types of the NFC tag areType1, Type2, Type3, and Type4. For a manner in which the NFC controllerreads the type of the tag, reference may be made to the NFC Forum Analogstandard, the NFC Forum Digit standard, and the NFC Forum Activitystandard.

The NFC controller may discover the tag and acquire an attribute of thetag by means of radio frequency discovery. For processes in which howthe NFC controller discovers the tag and acquires the attribute of thetag by means of the radio frequency discovery, reference may be made tothe NFC Forum Analog standard, the NFC Forum Digit standard, and the NFCForum Activity standard. The attribute of the tag may include a formatof the tag, a data type of the tag, a function supported by the tag, andthe like. The function supported by the tag herein refers to acapability that is required in a process of establishing communicationbetween the NFC controller and the tag.

102: The NFC controller determines whether a format of the tag is anNDEF according to the type of the tag.

The NDEF defines an encapsulation format of information duringinformation exchange, where the information is transmitted between NFCterminals or between an NFC terminal and an NFC tag. The NDEF may be alightweight binary message format, and it can be used to encapsulate oneor more user-defined data of any type and any size.

When the type of the tag is Type 1, the NFC controller determineswhether the format of the tag is the NDEF according to header read-onlymemory (Header Read-Only

Memory, HR)0 in the tag. Specifically, a length of HR0 is one byte, andwhen four high order bits of HR0 is 0001b, the NFC controller determinesthat the format of the tag is the NDEF. When the type of the tag is Type2, the NFC controller determines whether the format of the tag is theNDEF according to a capability container (Capability Container, CC) inthe tag. Specifically, a length of the CC is four bytes, and when avalue of the first byte is E1h (where E1 is in hexadecimal format), theNFC controller determines that the format of the tag is the NDEF. Whenthe type of the tag is Type 3, the NFC controller determines whether theformat of the tag is the NDEF according to System Code in the tag.Specifically, a length of the System Code is two bytes, and when a valueof the System Code is 12FCh (where 12FC is in hexadecimal format), theNFC controller determines that the format of the tag is the NDEF. Whenthe type of the tag is Type 4, the NFC controller determines whether theformat of the tag is the NDEF according to a file identifier of acapability container (Capability Container, CC) file in the tag.Specifically, a length of the file identifier of the CC file is twobytes, and when a value of the file identifier of the CC file is E103h(where E103 is in hexadecimal format), the NFC controller determinesthat the format of the tag is the NDEF.

Optionally, when the NFC controller determines that the format of thetag is the NDEF, the NFC controller may further determine a data type ofthe tag. The tag has eight data types. Specifically, the NFC controlleracquires data type information from a TNF field of the tag (Type 1, Type2, Type 3, and Type 4), and determines the data type of the tagaccording to content of the data type information. A value of the TNFfield may be 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, or 0x07, and theNFC controller may determine the data type information of the tagaccording to the value of the TNF field. The data type of the tag isspecifically a type of an NDEF message. 0x00 represents that the NDEFmessage is an empty message; 0x01 represents that the NDEF messagestores an internal data type defined in the RTD (Record Type Define)standard by the NFC Forum standards organization; 0x02 represents thatthe NDEF message stores a media type defined in the RFC (Request ForComments) 2046 standard, such as a picture and voice; 0x03 representsthat the NDEF message stores a uniform resource identifier (UniformResource Identifier, URI) defined in the RFC 3986 standard; 0x04represents that the NDEF message stores an external data type defined inthe RTD (Record Type Define) standard by the NFC Forum standardsorganization; 0x05 represents that the NDEF message stores one piece ofdata of an unknown type; 0x06 represents that the NDEF message is anintermediate tag among a series of consecutive NDEF tags, where a datatype of the tag is the same as that of a previous NDEF tag; and 0x07represents that the NDEF message is reserved and not in use temporarily.

103: The NFC controller sends a notification message to a device hostwhen the NFC controller determines that the format of the tag is theNDEF, where the notification message includes information that theformat of the tag is the NDEF.

The device host is responsible for managing a running environment of theNFC terminal and a peripheral, including managing the NFC controller,such as initialization, configuration and power management. In theexample of a mobile phone having an NFC function, the device host mayrefer to a CPU of the mobile phone.

In this embodiment, for example, the NFC controller sends thenotification message to the device host; for example, the notificationmessage is a radio frequency discovery notification RF_DISCOVER_NFT. Aspecific form of RF_DISCOVER_NFT is shown in Table 1.

TABLE 1 RF_DISCOVER_NTF NDEF Info 1 Octet X A nonzero value indicatesthat a format of a tag is an NDEF, and zero indicates that the format ofthe tag is not the NDEF

In Table 1, examples of meanings or values indicated by fields are asfollows:

NDEF Info indicates NDEF information, which occupies one byte (1 Octet);

X indicates whether a format of a tag is an NDEF; and

when X0000 0000, it indicates that the format of the tag is the NDEF.

Optionally, when the NFC controller determines that the format of thetag is not the NFC data exchange format, the NFC controller still cansend a notification message to the device host. When X in thenotification message (RF_DISCOVER_NFT) meets X=0000 0000, it indicatesthat the format of the tag is not the NDEF.

Optionally, the notification message sent by the NFC controller to thedevice host may further include the data type of the tag. For example,the NFC controller sends RF_DISCOVER_NFT to the device host, and aspecific form of RF_DISCOVER_NFT is shown in Table 2.

TABLE 2 RF_DISCOVER_NTF NDEF Info 1 Octet X A nonzero value indicatesthat a format of a tag is an NDEF, and zero indicates that the format ofthe tag is not the NDEF TNF 1 Octet X X indicates a data type of a tag

In Table 2, examples of meanings or values indicated by fields are asfollows:

for detailed descriptions of NDEF Info, reference may be made to thedescriptions in Table 1, and details are not described herein again;

type name format (Type Name Format, TNF) indicates information about adata type of a tag, and occupies one byte (1 Octet);

when X=0x00, it indicates that an NDEF message is an empty message (thetag includes the NDEF message); and

when X=0x01, it indicates that the NDEF message stores an internal datatype defined in the RTD (Record Type Define) standard by the NFC Forumstandards organization, and the like.

It should be noted that, X is not limited to indicating a specific datatype of a tag in this embodiment. For example, when X=0x07, it indicatesthat the NDEF message is reserved and not in use temporarily.

According to the tag identification method provided in this embodimentof the present invention, the NFC controller reads the type of the tag;and determines whether the format of the tag is the NFC data exchangeformat according to the type of the tag; and the NFC controller sendsthe notification message to the device host when the NFC controllerdetermines that the format of the tag is the NFC data exchange format,where the notification message includes information that the format ofthe tag is the NFC data exchange format. Compared with the prior art inwhich the device host can determine the format of the NFC tag only byacquiring entire content of the NFC tag, which causes the device host toread a large amount of data of the NFC tag and perform relativelycomplex operations, this embodiment of the present invention canimplement reducing steps of determining the format of the tag by thedevice host in the NFC terminal, so that the NFC tag can be processed.

In another embodiment of the present invention, a tag identificationmethod is provided. As shown in FIG. 2, the method includes:

201: An NFC controller sends a format function message to a device host,where the format function message carries information about whether theNFC controller has a capability of performing NDEF detection on a tag.

Optionally, the NFC controller sends the format function message to thedevice host in the following two manners:

Manner 1: The device host sends an initialization command to the NFCcontroller; the NFC controller sends an initialization response to thedevice host after receiving the initialization command, that is, theformat function message is specifically the initialization response,where the initialization command is used to initialize the NFCcontroller. For example, the device host sends CORE_INIT_CMD (aninitialization command) to the NFC controller, that is, the device hostinitializes the NFC controller; and then the NFC controller feeds backCORE_INIT_RSP (an initialization response) to the device host afterreceiving CORE_INIT_CMD. In the CORE_INIT_RSP response, when a SupportedRF Interface field includes 0x04, that is, NDEF Access RF Interface, itindicates that the NFC controller has a capability of detecting theNDEF.

Manner 2: The device host sends a format query command to the NFCcontroller; the NFC controller sends an format query response to thedevice host after receiving the format query command, that is, theformat function message is specifically the format query response. Forexample, the device host sends FORMAT_INQ_CMD (a format query command)to the NFC controller, and then the NFC controller feeds backFORMAT_INQ_RSP (a format query response) to the device host afterreceiving FORMAT_INQ_CMD.

Certainly, this embodiment is not limited to the foregoing two mannersthat are used as examples. The NFC controller may further add, to amessage sent to the device host, information about whether the NFCcontroller has a capability of performing NDEF detection on the tag.

202: The device host sends a configuration command to the NFCcontroller, where the configuration command is used to indicate whetherthe NFC controller performs NDEF detection on the tag.

For example, the device host sends a CORE_SET_CONFIG_CMD command to theNFC controller, where the CORE_SET_CONFIG_CMD command includes a formatparameter. A specific form of the format parameter is shown in Table 3.

TABLE 3 CORE_SET_CONFIG_CMD Parameter 1 3 ID 1 Octet 0xA0 Octets Len 1Octet 1 Val 1 Octet Zero indicates that NDEF detection is not performed,and a nonzero value indicates that the NDEF detection is performed

In Table 3, examples of meanings or values indicated by fields are asfollows:

Parameter 1 indicates a format parameter, and the format parameter hasthree bytes (3 Octets);

ID (identifier) occupies one byte (1 Octet), and 0xA0 indicates anidentifier of the format parameter;

Len (length) occupies one byte (1 Octet), and 1 indicates that a lengthof Val is one byte; and

Val (value) occupies one byte (1 Octet), and when a value of Val is 00000000, it indicates that the configuration command instructs the NFCcontroller not to perform NDEF detection on a tag; when a value of Valis not zero (for example, 0000 0001), it indicates that theconfiguration command instructs the NFC controller to perform NDEFdetection on the tag.

It should be noted that, a value of a byte occupied by Parameter 1 isnot limited in this embodiment; when a byte occupied by ID, Len, or Valincluded in Parameter 1 changes, the value of the byte occupied byParameter 1 may also change.

Optionally, the configuration command is further used to indicate thatthe NFC controller performs data type detection on the tag. When theCORE_SET_CONFIG_CMD command sent by the device host to the NFCcontroller is further used to indicate that the NFC controller performsdata type detection on the tag, the CORE_SET_CONFIG_CMD command includesa format parameter and a data type parameter, where there are tworepresentation manners for CORE_SET_CONFIG_CMD, and the specific formsare shown in Table 4 and Table 5.

TABLE 4 CORE_SET_CONFIG_CMD Parameter 1 3 Octets ID 1 Octet 0xA0 Len 1Octet 1 Val 1 Octet Zero indicates that NDEF detection is not performed,and a nonzero value indicates that the NDEF detection is performedParameter 2 3 Octets ID 1 Octet 0xA1 Len 1 Octet 1 Val 1 Octet Xindicates a data type of a tag that needs to be detected

For detailed descriptions of the format parameter Parameter 1, referencemay be made to the descriptions in Table 3, and details are notdescribed herein again.

In Table 4, examples of meanings or values indicated by fields are asfollows:

Parameter 2 indicates a data type parameter, and the data type parameterhas three bytes (3 Octets);

ID (identifier) occupies one byte (1 Octet), and 0xA1 indicates anidentifier of the data type parameter;

Len (length) occupies one byte (1 Octet), and 1 indicates that a lengthof Val is one byte; and

Val (value) occupies one byte (1 Octet), and when a value X of Val is0101 0000, it indicates that the configuration command instructs the NFCcontroller to perform detection on the second and fourth data types. Itcan be understood that, the tag has eight data types; the device hostarranges the eight data types in a specific sequence, and makes each bitof a value of Val correspond to one data type. When a bit in X is 1, itindicates a data type corresponding to the bit needs to be detected;when the bit is 0, it indicates a data type corresponding to the bitdoes not need to be detected. For example, a sequence, from the firsttype to the eighth type, of the eight data types is as follows: 0x00,0x01, 0x02, 0x03, 0x04, 0x05, 0x06, and 0x07. Correspondingly, the firstbit is corresponding to 0x00, the second bit is corresponding to 0x01,the third bit is corresponding to 0x02, the fourth bit is correspondingto 0x03, and by analogy, the eighth bit is corresponding to 0x07.According to a requirement of the configuration command in Table 4, theNFC controller detects whether the data type of the tag is either of thetwo data types: 0x01 or 0x03.

TABLE 5 CORE_SET_CONFIG_CMD Parameter 1 3 Octets ID 1 Octet 0xA0 Len 1Octet 1 Val 1 Octet Zero indicates that NDEF detection is not performed,and a nonzero value indicates that the NDEF detection is performedParameter 2 3 Octets ID 1 Octet 0xA1 Len 1 Octet 1 Val 1 Octet Zeroindicates data type detection is not performed, and a nonzero valueindicates the data type detection is performed

In Table 5, examples of meanings or values indicated by fields are asfollows:

for detailed descriptions of the format parameter Parameter 1, referencemay be made to the descriptions in Table 3, and details are notdescribed herein again;

Parameter 2 indicates a data type parameter, and the data type parameterhas three bytes (3 Octets);

ID (identifier) occupies one byte (1 Octet), and 0xA1 indicates anidentifier of the data type parameter;

Len (length) occupies one byte (1 Octet), and 1 indicates that a lengthof Val is one byte; and

Val (value) occupies one byte (1 Octet), and when a value of Val is 00000000, it indicates that the configuration command instructs the NFCcontroller not to perform data type detection on a tag; when a value ofVal is not zero (for example, 0000 0001), it indicates that theconfiguration command instructs the NFC controller to perform data typedetection on the tag.

In this step, for descriptions of the device host, the NFC controller,and the NDEF, reference may be made to step 102 in FIG. 1.

203: The NFC controller sends a configuration command response messageto the device host.

After receiving the configuration command sent by the device host, theNFC controller sends the configuration command response message to thedevice host, where the configuration command response message may beCORE_SET_CONFIG RSP.

204: The device host sends a radio frequency discovery start command tothe NFC controller.

After receiving the configuration command response message sent by theNFC controller, the device host sends the radio frequency discoverystart command to the NFC controller; or the device host waits, aftersending the configuration command, for a predetermined time to start tosend the radio frequency discovery start command to the NFC controller.For example, the device host sends RF_DIS_CMD (a radio frequencydiscovery start command) to the NFC controller.

A range of the predetermined time is not limited in this embodiment. Forexample, when the predetermined time is 200 ms, the device host startsto send the radio frequency discovery start command to the NFCcontroller 200 ms after sending the configuration command to the NFCcontroller.

205: The NFC controller sends a radio frequency discovery responsemessage to the device host, and starts radio frequency discovery to reada type of the tag.

The radio frequency discovery response message includes notificationinformation that the NFC controller has received the radio frequencydiscovery start command. For example, the NFC controller sendsRF_DIS_RSP (a radio frequency discovery response message) to the devicehost.

206: The NFC controller determines whether a format of the tag is anNDEF according to the type of the tag.

For a manner in which the NFC controller determines whether a format ofthe tag is an NDEF, reference may be made to step 102 in FIG. 1, anddetails are not described herein again.

207: When determining that the format of the tag is the NDEF, the NFCcontroller determines the data type of the tag.

It should be noted that, this step is an optional step, and the NFCcontroller needs to execute step 207 only when the configuration commandfurther includes information indicating that the NFC controller detectsthe data type of the tag. Therefore, in FIG. 2, step 207 is expressedwith a dashed line box.

For a manner in which the NFC controller determines a data type of thetag, reference may still be made to step 102 in FIG. 1.

208: The NFC controller sends a notification message to the device host.

For detailed descriptions of the notification message, reference may bemade to step 103 in FIG. 1.

209: When the format of the tag is the NDEF, the device host establishesan NDEF radio frequency interface.

The NDEF radio frequency interface is an interface between the devicehost and the NFC controller. The NFC controller sends data transmittedbetween the NFC controller and the tag (where the format of the tag isthe NDEF) to the device host by using the NDEF radio frequencyinterface; or the device host first sends, to the NFC controller byusing the NDEF radio frequency interface, data to be sent to the tag,and then the NFC controller forwards the data to the tag.

Specifically, the device host sends RF_DISCOVER_SELECT_CMD (a radiofrequency discovery select command) to the NFC controller, where theRF_DISCOVER_SELECT_CMD includes information that the device host hasestablished the NDEF radio frequency interface. A specific form ofRF_DISCOVER_SELECT_CMD is shown in Table 6.

TABLE 6 RF_DISCOVER_SELECT_CMD RF Discovery ID XX RF Protocol TagProtocol RF Interface NDEF RF Interface

In Table 6, examples of meanings or values indicated by fields are asfollows:

RF Discovery ID indicates a radio frequency discovery identifier, and isused to identify a tag corresponding to radio frequency discovery;

XX indicates an identifier of the tag;

RF Protocol indicates a manner of communication between the NFCcontroller and the tag (for example, the Tag Protocol); and

RF Interface indicates an interface between the device host and the NFCcontroller (for example, the NDEF radio frequency interface).

After the NDEF radio frequency interface is established between thedevice host and the NFC controller, and after the NFC controllerreceives the data sent by the device host, the NFC controller mayconvert the data into data in a format that can be received by the tag.The tag is a tag that is identified by an RF Discover ID correspondingto the NDEF radio frequency interface.

It can be understood that, in step 201 to step 209, an interface used bythe NFC controller to perform interaction with the device host may be anNFC controller interface (NFC controller Interface, NCI). The NCI is alogical interface between the device host and the NFC controller, andthe NCI is configured to transmit various commands between the devicehost and the NFC controller.

210: The device host sends a read/write command to the NFC controller byusing the NDEF radio frequency interface.

The read/write command is used to acquire the data in the tag, or theread/write command is used to modify the data in the tag.

211: The NFC controller converts the read/write command into an NDEFread/write command, and then performs data reading/writing on the tagaccording to the NDEF read/write command.

Content of read/write commands received by different types of NFC tagsis different. For example, a read/write command received by a Type 1 tagis Read, and a read/write command received by a Type 2 tag is R. The NFCcontroller converts, by using the NDEF radio frequency interface, theread/write command sent by the device host into NDEF read/write commandscorresponding to different types of tags. The NDEF read/write commandmay be an NDEF read command, or may be an NDEF write command.

For example, the NFC controller sends an NDEF read command to the NFCtag, where the NDEF read command instructs the NFC tag to send data inthe tag. After receiving the NDEF read command, the NFC tag sends thedata in the tag to the NFC controller.

212: The NFC controller sends the data in the tag to the device host.

213: The device host sends the received data in the tag to an NFCapplication.

It should be noted that, before step 213, the device host may receive aregistration message sent by the NFC application. Specifically, afterbeing installed or when running for the first time, the NFC applicationperforms registration with the device host according to a capability, ofprocessing a data type of a tag, of the NFC application. For example, abrowser application program supporting NFC scanning may register a datatype, namely URI (0x03), with the device host.

When the notification message includes that the format of the tag is theNDEF, the device host sends the data in the tag to a runningapplication. For example, running applications include a browsersupporting NFC scanning, a video player supporting the NFC scanning, anda photo album supporting the NFC scanning. The device host sends thedata in the tag to the foregoing three running applications, and theforegoing three running applications process the tag according to anactual situation (a capability, of processing a data type of a tag, ofan application).

When the notification message includes that the format of the tag is theNDEF and includes the data type of the tag, the device host sends thedata in the tag to an application corresponding to the data type. Forexample, running applications include a browser supporting NFC scanning,a video player supporting the NFC scanning, and a photo album supportingthe NFC scanning. If the data type of the tag is URI (0x03), the devicehost sends, according to the data type of the tag, the data in the tagto the browser supporting the NFC scanning.

According to the tag identification method provided in this embodimentof the present invention, it can be implemented that the device host inthe NFC terminal determines the format of the tag and the data type ofthe tag by using the NFC controller. After obtaining the format of thetag and the data type of the tag, the device host sends, according tothe data type of the tag, data in the tag to an applicationcorresponding to the data type of the tag for processing, so that thedevice host can determine the format of the tag and the data type of thetag without requiring analyzing entire content of the tag; in addition,the NDEF radio frequency interface established by the device host canenable the data in the NFC tag to be transmitted between the device hostand the NFC controller, thereby achieving an objective that the tag canbe processed by the device host.

In an implementation manner of this embodiment of the present invention,a transmission interface between a device host and an NFC controller isclearly described. As shown in FIG. 3, before the device host receives anotification message sent by the NFC controller (that is, before thedevice host establishes an NDEF radio frequency interface), commandtransmission between the device host and the NFC controller is performedby using an NCI; and after the device host receives the notificationmessage sent by the NFC controller, the device host establishes the NDEFradio frequency interface, and NDEF data transmission between the devicehost and the NFC controller is performed by using the NDEF radiofrequency interface.

As shown in FIG. 4, an embodiment of the present invention provides atag identification apparatus 40, including: a reading module 401, adetermining module 402, and a sending module 403. The apparatus may be aunit of an NFC terminal, for example, an NFC controller.

The reading module 401 is configured to read a type of a tag.

The determining module 402 is configured to determine whether a formatof the tag is an NDEF according to the type of the tag, and send aresult of the determining to the sending module 403.

The sending module 403 is configured to send a notification message to adevice host when the determining module 402 determines that the formatof the tag is the NDEF, where the notification message includes that theformat of the tag is the NDEF.

For detailed descriptions of the notification message, reference may bemade to step 103 in FIG. 1.

Further, as shown in FIG. 5, in a tag identification apparatus 50, thetag identification apparatus 50 further includes: a receiving module404, a converting module 405, a processing module 406.

Specifically, before the reading module 401 reads the type of the tag,the sending module 403 sends a format function message to the devicehost, where the format function message carries information aboutwhether the NFC controller has a capability of performing NDEF detectionon the tag. Specifically, the format function message may be aninitialization response. For example, the receiving module 404 receivesan initialization command sent by the device host; then the sendingmodule 403 sends the initialization response to the NFC controller,where the initialization response carries the information about whetherthe NFC controller has a capability of performing NDEF detection on thetag.

When the initialization response carries the information about whetherthe NFC controller has a capability of performing NDEF detection on thetag, the receiving module 404 receives a configuration command sent bythe device host, where the configuration command is used to indicatewhether the NFC controller performs NDEF detection on the tag. It can beunderstood that, when the configuration command indicates that the NFCcontroller needs to perform NDEF detection on the tag, the readingmodule 401 reads the type of the tag.

Optionally, the configuration command is further used to indicate thatthe NFC controller performs data type detection on the tag.

Further, when the type of the tag is Type 1, the determining module 402determines whether the format of the tag is the NDEF according to HR0 inthe tag; when the type of the tag is Type 2, the determining module 402determines whether the format of the tag is the NDEF according to a CCin the tag; when the type of the tag is Type 3, the determining module402 determines whether the format of the tag is the NDEF according toSystem Code in the tag; and when the type of the tag is Type 4, thedetermining module 402 determines whether the format of the tag is theNDEF according to a file identifier of a CC file in the tag.

Further, after the sending module 403 sends the notification message tothe device host, the receiving module 404 receives, by using an NDEFradio frequency interface, a read/write command sent by the device host,the converting module 405 converts the read/write command into an NDEFread/write command, and then the processing module 406 performs datareading/writing on the tag according to the NDEF read/write command.

According to the tag identification apparatus provided in thisembodiment of the present invention, it can be implemented that thedevice host in the NFC terminal determines the format of the tag and thedata type of the tag by using the NFC controller. After obtaining theformat of the tag and the data type of the tag, the device host sends,according to the data type of the tag, data in the NFC tag to anapplication corresponding to the data type of the tag for processing, sothat the device host can determine the format of the tag and the datatype of the tag without requiring analyzing entire content of the NFCtag.

As shown in FIG. 6, an embodiment of the present invention provides atag identification apparatus 60, including: an NFC controller 601 and adevice host 602, where the NFC controller 601 is connected to the devicehost 602.

The NFC controller 601 is configured to read a type of a tag; anddetermine whether a format of the tag is an NFC data exchange formatNDEF according to the type of the tag; and the NFC controller 601 sendsa notification message to the device host 602 when the NFC controller601 determines that the format of the tag is the NDEF, where thenotification message includes that the format of the tag is the NDEF.

When the type of the tag is Type 1, the NFC controller 601 determineswhether the format of the tag is the NDEF according to HR0 in the tag;when the type of the tag is Type 2, the NFC controller 601 determineswhether the format of the tag is the NDEF according to a CC in the tag;when the type of the tag is Type 3, the NFC controller 601 determineswhether the format of the tag is the NDEF according to System Code inthe tag; and when the type of the tag is Type 4, the NFC controller 601determines whether the format of the tag is the NDEF according to a fileidentifier of a CC file in the tag.

For detailed descriptions of the notification message, reference may bemade to step 103 in FIG. 1.

The device host 602 is configured to receive the notification messagesent by the NFC controller 601.

Further, the NFC controller 601 is further configured to send a formatfunction message to the device host 602, where the format functionmessage carries information about whether the NFC controller 601 has acapability of performing NDEF detection on the tag. Specifically, theformat function message may be an initialization response. For example,the device host 602 first sends an initialization command to the NFCcontroller 601. After receiving the initialization command sent by thedevice host 602, the NFC controller 601 sends the initializationresponse to the device host 602, where the initialization responsecarries the information about whether the NFC controller has acapability of performing NDEF detection on the tag.

Further, the device host 602 is further configured to send aconfiguration command to the NFC controller, where the configurationcommand is used to indicate whether the NFC controller 601 performs NDEFdetection on the tag.

The NFC controller 601 is further configured to receive theconfiguration command sent by the device host 602.

Optionally, the configuration command is further used to indicate thatthe NFC controller 601 performs data type detection on the tag.

Further, the device host 602 is further configured to establish an NDEFradio frequency interface for performing data transmission with the NFCcontroller 601 after receiving the notification message sent by the NFCcontroller 601.

Further, the device host 602 is further configured to send a read/writecommand to the NFC controller 601 by using the NDEF radio frequencyinterface.

The NFC controller 601 is further configured to receive, by using theNDEF radio frequency interface, the read/write command sent by thedevice host 602; convert the read/write command into an NDEF read/writecommand; and perform data reading/writing on the tag according to theNDEF read/write command.

The apparatus shown in FIG. 6 may be an NFC terminal, where the NFCterminal may be a terminal having an NFC function, such as a mobilephone, a tablet computer, and a camera.

It should be noted that, because content such as specific implementationprocesses of modules and information exchange between the modules in theapparatus 60 shown in FIG. 6 is based on a same invention concept asmethod embodiments of the present invention, reference may be made tothe method embodiments, and details are not described herein again.

According to the tag identification apparatus provided in thisembodiment of the present invention, it can be implemented that thedevice host in the NFC terminal determines the format of the tag and thedata type of the tag by using an NFC controller. After obtaining theformat of the tag and the data type of the tag, the device host sends,according to the data type of the tag, data in the NFC tag to anapplication corresponding to the data type of the tag for processing, sothat the device host can determine the format of the tag and the datatype of the tag without requiring analyzing entire content of the NFCtag.

It may be clearly understood by a person skilled in the art that, forthe purpose of convenient and brief description, division of theforegoing function modules is taken as an example for illustration. Inactual application, the foregoing functions can be allocated todifferent function modules and implemented according to a requirement,that is, an inner structure of an apparatus is divided into differentfunction modules to implement all or some of the functions describedabove. For a detailed working process of the foregoing system,apparatus, and unit, reference may be made to a corresponding process inthe foregoing method embodiments, and details are not described hereinagain.

In the several embodiments provided in the present application, itshould be understood that the disclosed apparatus and method may beimplemented in other manners. For example, the described apparatusembodiment is merely exemplary. For example, the module or unit divisionis merely logical function division and may be other division in actualimplementation. For example, a plurality of units or components may becombined or integrated into another system, or some features may beignored or not performed. In addition, the displayed or discussed mutualcouplings or direct couplings or communication connections may beimplemented by using some interfaces. The indirect couplings orcommunication connections between the apparatuses or units may beimplemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected according toactual needs to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of the presentinvention may be integrated into one processing unit, or each of theunits may exist alone physically, or two or more units are integratedinto one unit. The integrated unit may be implemented in a form ofhardware, or may be implemented in a form of a software functional unit.

When the integrated unit is implemented in the form of a softwarefunctional unit and sold or used as an independent product, theintegrated unit may be stored in a computer-readable storage medium.Based on such an understanding, the technical solutions of the presentinvention essentially, or the part contributing to the prior art, or allor some of the technical solutions may be implemented in the form of asoftware product. The computer software product is stored in a storagemedium and includes several instructions for instructing a computerdevice (which may be a personal computer, a server, or a network device)or a processor to perform all or some of the steps of the methodsdescribed in the embodiments of the present invention. The foregoingstorage medium includes: any medium that can store program code, such asa USB flash drive, a removable hard disk, a read-only memory (ROM,Read-Only Memory), a random access memory (RAM, Random Access Memory), amagnetic disk, or an optical disc.

The foregoing descriptions are merely specific implementation manners ofthe present invention, but are not intended to limit the protectionscope of the present invention. Any variation or replacement readilyfigured out by a person skilled in the art within the technical scopedisclosed in the present invention shall fall within the protectionscope of the present invention. Therefore, the protection scope of thepresent invention shall be subject to the protection scope of theclaims.

What is claimed is:
 1. A tag identification method, comprising: reading,by a Near Field Communication (NFC) controller, a type of a tag;performing, by the NFC controller, NFC data exchange format (NDEF)detection on the tag according to the type of the tag; and sending, bythe NFC controller, a notification message to a device host when theNDEF detection indicates a presence of an NDEF message in the tag,wherein the notification message comprises the presence of the NDEFmessage in the tag.
 2. The method according to claim 1, wherein theperforming, by the NFC controller, the NDEF detection on the tagaccording to the type of the tag comprises: when the type of the tag isType 1, performing, by the NFC controller, the NDEF detection on the tagaccording to header read-only memory HR0 in the tag.
 3. The methodaccording to claim 1, wherein the performing, by the NFC controller, theNDEF detection on the tag according to the type of the tag comprises:when the type of the tag is Type 2, performing, by the NFC controller,the NDEF detection on the tag according to a capability container (CC)in the tag.
 4. The method according to claim 1, wherein the performing,by the NFC controller, the NDEF detection on the tag according to thetype of the tag comprises: when the type of the tag is Type 3,performing, by the NFC controller, the NDEF detection on the tagaccording to System Code in the tag.
 5. The method according to claim 1,wherein the performing, by the NFC controller, the NDEF detection on thetag according to the type of the tag comprises: when the type of the tagis Type 4, performing, by the NFC controller, the NDEF detection on thetag according to a file identifier of a capability container (CC) filein the tag.
 6. The method according to claim 1, further comprising:receiving, by the NFC controller via an NDEF radio frequency interface,a read/write command sent by the device host; converting, by the NFCcontroller, the read/write command into an NDEF read/write command; andperforming, by the NFC controller, data reading/writing on the tagaccording to the NDEF read/write command.
 7. A tag identificationapparatus, comprising: a Near Field Communication (NFC) controller; anda device host coupled to the NFC controller, wherein the NFC controlleris configured to: read a type of a tag; perform NFC data exchange format(NDEF) detection on the tag according to the type of the tag; and send anotification message to the device host when the NDEF detectionindicates a presence of an NDEF message in the tag, wherein thenotification message comprises the presence of the NDEF message in thetag.
 8. The apparatus according to claim 7, wherein when the type of thetag is Type 1, the NFC controller is configured to perform the NDEFdetection on the tag according to header read-only memory HR0 in thetag.
 9. The apparatus according to claim 7, wherein when the type of thetag is Type 2, the NFC controller is configured to perform the NDEFdetection on the tag according to a capability container (CC) in thetag.
 10. The apparatus according to claim 7, wherein when the type ofthe tag is Type 3, the NFC controller is configured to perform the NDEFdetection on the tag according to System Code in the tag.
 11. Theapparatus according to claim 7, wherein when the type of the tag is Type4, the NFC controller is configured to perform the NDEF detection on thetag according to a file identifier of a capability container (CC) filein the tag.
 12. The apparatus according to claim 7, wherein the NFCcontroller is configured to: receive a read/write command via an NDEFradio frequency interface, wherein the read/write command is sent by thedevice host; convert the read/write command into an NDEF read/writecommand; and perform data reading/writing on the tag according to theNDEF read/write command.